package com.erp.myAdapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.ClientJiaoliuBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_jiaoloiu_item.view.*

/**
 * Created by Administrator on 2017/1/3/003.
 * 作者：刘洋
 */
class JiaoliuAdapter(private var mlist: List<ClientJiaoliuBean>, private val mcontext: Context) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)
    override fun getCount(): Int {
        return mlist.size+1
    }

    override fun getItem(position: Int): Any {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    @SuppressLint("ViewHolder")
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v = minflater.inflate(R.layout.lv_jiaoloiu_item, null)
      if(position<mlist.size) {
            v.IvAdd.visibility=View.GONE
            v.LlShuJu.visibility=View.VISIBLE
            var jiaoliuBean = mlist[position]
            Myutil.settv(jiaoliuBean.relative_people, v.TvAssPeople)
            Myutil.settv(jiaoliuBean.content, v.TvContent)
            Myutil.settv(Myutil.getdata(jiaoliuBean.appointment_communication), v.TvAppointmentCommunication)
            Myutil.settv(Myutil.getdata(jiaoliuBean.communication_time), v.TvCommunicationTime)
        }else{
          v.IvAdd.visibility=View.VISIBLE
          v.LlShuJu.visibility=View.GONE
      }
        return v
    }

    fun Allnotifi(list: List<ClientJiaoliuBean>) {
        this.mlist = list
        notifyDataSetChanged()
    }
}
